<?php

namespace App\Http\Controllers\Api;

class WxappController extends ApiBase
{
    /**
     * 
     * 获取openid
     * 
     */
    public function wxappOpenId(\App\Server\Wxapp\OpenId $openIdServer)
    {
        return $openIdServer->get();
    }

    /**
     * 
     * 获取access token
     * 
     */
    public function wxappAccessToken(\App\Server\Wxapp\AccessToken $accessToken)
    {
        return $accessToken->get();
    }

    /**
     * 
     * 获取页面小程序二维码
     * 
     */
    public function wxappStoreQrcode(\App\Server\Wxapp\AccessToken $at, \App\Server\Wxapp\StoreQrcode $qrCode)
    {
        return $qrCode->get($at->get(),[
            "page" => "pages/test/test",
            "scene"=> "id=9256",
            "check_path" => false,
            "env_version"=> "trial"
        ]);
    }

    /**
     * 
     * 微信支付成功通知
     * 
     */
    public function paidNotify(\App\Server\Wxapp\Pay $payServer, \App\Server\Goods\Order $order)
    {
        return $payServer->paidNotify($order->paymentSuccess());
    }

    /**
     * 
     * 微信支付退款通知
     * 
     */
    public function refundedNotify(\App\Server\Wxapp\Pay $payServer, \App\Server\Goods\Order $order)
    {
        return $payServer->refundedNotify($order->refundedSuccess());
    }
}
